import { Define, EntityObjectFactory } from 'tiny-entity2';
const EntityObjectType = EntityObjectFactory.GetEntityObjectType(process.env.dataBaseType || 'mysql');
import { TableProduct } from './tableProduct';
import { TableServiceLog } from './tableServiceLog';

@Define.Table({ TableName: 'desktable' })
export class DeskTable extends EntityObjectType<DeskTable> {
    @Define.PrimaryKey()
    id: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        NotAllowNULL: true,
        IsIndex: true
    })
    storeId: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        NotAllowNULL: true
    })
    name: string;

    @Define.Column({
        DataType: Define.DataType.INT,
        DefaultValue: 0
    })
    indexNo: number;

    @Define.Column({
        DataType: Define.DataType.BIGINT
    })
    createTime: number;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        DataLength: 20,
        DefaultValue: 'physical'
    })
    type: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        DataLength: 20
    })
    status: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        DataLength: 40
    })
    tableZoneId: string;

    @Define.Column({
        DataType: Define.DataType.INT
    })
    customerCount: number;

    @Define.Column({
        DataType: Define.DataType.BIGINT
    })
    version: number;

    @Define.Mapping({
        Mapping: 'TableProduct',
        MappingKey: 'deskTableId'
    })
    tableProducts: TableProduct[];

    @Define.Mapping({
        Mapping: 'TableServiceLog',
        MappingKey: 'tableId',
        MappingType: Define.MappingType.One
    })
    tableServiceLog: TableServiceLog;
}

export const DeskTableType = {
    Physical: 'physical',
    Virtual: 'virtual'
}